package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.CooperativeEnterprise;
import com.zygh.interactiveplatform.module.service.CooperativeEnterpriseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-02-02
 */
@RestController
@RequestMapping("/cooperative-enterprise")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_COOPERATIVE})
public class CooperativeEnterpriseController {
    @Resource
    private CooperativeEnterpriseService cooperativeEnterpriseService;

    @ApiOperation(value = "合作公司新增", notes = "合作公司新增")
    @PostMapping("addCooperativeEnterprisee")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_COOPERATIVE, content = "合作公司新增")
    public ResponseDTO addCooperativeEnterprisee(@RequestBody @Valid CooperativeEnterprise cooperativeEnterprise) {
        return cooperativeEnterpriseService.addCooperativeEnterprise(cooperativeEnterprise);
    }
    @ApiOperation(value = "合作公司修改", notes = "合作公司修改")
    @PostMapping("updateCooperativeEnterprise")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_COOPERATIVE, content = "合作公司修改")
    public ResponseDTO updateCooperativeEnterprise(@RequestBody @Valid CooperativeEnterprise cooperativeEnterprise) {
        return cooperativeEnterpriseService.updateCooperativeEnterprise(cooperativeEnterprise);
    }
    @ApiOperation(value = "合作公司删除", notes = "合作公司删除")
    @PostMapping("deleteCooperativeEnterprise")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_COOPERATIVE, content = "合作公司删除")
    public ResponseDTO deleteCooperativeEnterprise(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return cooperativeEnterpriseService.deleteCooperativeEnterprise(new_id);
    }
    @ApiOperation(value = "查询所有合作公司", notes = "查询所有合作公司")
    @GetMapping("findCooperativeEnterpriseAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_COOPERATIVE, content = "查询所有合作公司")
    public ResponseDTO findCooperativeEnterpriseAll(Integer current, Integer size) {
        return cooperativeEnterpriseService.findCooperativeEnterpriseAll(current,size);
    }
}
